import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:razer_one/app/main/constants/color_constants.dart';
import 'package:razer_one/app/main/view/main_btn.dart';
import 'package:razer_one/app/main/view/main_segment_view.dart';
import 'package:razer_one/app/main/view/main_text.dart';
import 'package:razer_one/app/main/view/main_textfield.dart';
import 'package:razer_one/app/modules/home/home_add/home_add_controller.dart';

class HomeAddPage extends GetView<HomeAddController> {
  const HomeAddPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<HomeAddController>(builder: (_) {
      return Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(
          title: const Text("添加任务"),
        ),
        body: GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTap: () {
            FocusScope.of(context).requestFocus(FocusNode());
          },
          child: ListView(
            padding: const EdgeInsets.all(20),
            children: [
              const Text.rich(TextSpan(children: [
                TextSpan(
                    text: '标题',
                    style: TextStyle(
                      fontSize: 15,
                      color: Color(kBlueColor),
                    )),
                TextSpan(
                    text: '  (最多20字)',
                    style: TextStyle(fontSize: 15, color: Colors.red)),
              ])),
              sizeH(5),
              MainTextField(
                "请输入标题",
                _.titleTF,
                width: double.infinity,
                maxLength: 20,
              ),
              sizeH(10),
              const Text.rich(TextSpan(children: [
                TextSpan(
                    text: '工作内容',
                    style: TextStyle(
                      fontSize: 15,
                      color: Color(kBlueColor),
                    )),
                TextSpan(
                    text: '  (最多200字)',
                    style: TextStyle(fontSize: 15, color: Colors.red)),
              ])),
              sizeH(10),
              MainTextField(
                "请输入工作内容",
                _.contentTF,
                isShowcounterText: true,
                fontSize: 15,
                maxLength: 200,
                maxLines: 7,
                height: 180,
                isShowCleanIcon: false,
              ),
              Row(
                children: [
                  const MainText(
                    "当前工作进度",
                    textColor: Color(kBlueColor),
                    fontSize: 16,
                  ),
                  sizeW(10),
                  Flexible(
                      child: MainSegmentView(
                    currentIndex: _.currentIndex,
                    handle: _.currentIndexChanged,
                  )),
                ],
              ),
              sizeH(10),
              Row(
                children: [
                  const MainText(
                    "预计需要时间",
                    textColor: Color(kBlueColor),
                    fontSize: 16,
                  ),
                  sizeW(10),
                  Expanded(
                      child: MainSelectBtn(
                    _.dateBtnTitle,
                    handle: _.showDateSelect,
                  )),
                ],
              ),
            ],
          ),
        ),
      );
    });
  }
}
